# -*- coding: utf-8 -*-
import pyExcelerator

class Exporter(object):

    def __init__(self):

        self.wb = pyExcelerator.Workbook()
        self.ws = self.wb.add_sheet('0')

    def export(self, table, file_name):

        for y in range(table.ROWS):
            for x in range(table.COLS):
                self.ws.write(y, x, table[y][x])

        file_name = self._get_file_name(file_name)
        self.wb.save(file_name)

    def _get_file_name(self, name):
        if ".xls" not in name:
            name += ".xls"
        return name
